﻿using System;
using System.Collections.Generic;
using System.Diagnostics.PerformanceData;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EventExample
{
    class Program
    {
        static void Main(string[] args)
        {
            PublishingHouse murzilka = new PublishingHouse();
            PublishingHouse ranok = new PublishingHouse();

            Subscriber s1 = new Subscriber("Maksim");
            Subscriber s2 = new Subscriber("Vasya");
            Subscriber s3 = new Subscriber("Petya");

            murzilka.NewMagazine += s1.SubscribeToMagazine;
            murzilka.NewMagazine += s2.SubscribeToMagazine;

            ranok.NewMagazine += s3.SubscribeToMagazine;


            murzilka.PublishMagazine("Murzilka", 1, "Murzilka is good", 5);

            Console.WriteLine();

            ranok.PublishMagazine("Men's Health", 100, "Special for Petya", 1);
        }
    }

    class Subscriber
    {
        private readonly string _name;

        public Subscriber(string name)
        {
            _name = name;
        }

        public void SubscribeToMagazine(object sender, NewMagazineEventArgs e)
        {
            Console.WriteLine("Hello, {0}\nNew magazine {1}, volume {2} was published. You can find it in the shop.", _name, e.MagazineName, e.Volume);
        }
    }
}


